package com.pb.infra.taskManage.controller;

import com.pb.infra.oth.entity.common.Result;
import com.pb.infra.oth.util.Constant;
import com.pb.infra.oth.util.SysLog;
import com.pb.infra.taskManage.service.TaskSelectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 任务配置
 * @author liaohaoyuan
 * @date 20210501
 */
@Slf4j
@RestController
@RequestMapping("v1/taskManage/taskSelect")
public class TaskSelectController {

    /**
     * 业务逻辑对象
     */
    @Resource
    private TaskSelectService taskSelectService;

    /**
     * 日志操作表
     */
    private static final String TABLE_NAME = "Ma_Dim_Job_Type";

    /**
     * 日志操作功能名
     */
    private static final String OPERATION_MENU = "任务配置";

    /**
     * 查询作业类型下拉列表
     *
     * @return Result 返回数据
     */
    @GetMapping(value = "getJobTypeList")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public List<Map<String, Object>> getJobTypeList() {
        return taskSelectService.getJobTypeList();
    }

    /**
     * 查询命令类型下拉列表
     *
     * @return Result 返回数据
     */
    @GetMapping(value = "getCmdTypeList")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public List<Map<String, Object>> getCmdTypeList() {
        return taskSelectService.getCmdTypeList();
    }

    /**
     * 查询运行频度下拉列表
     *
     * @return Result 返回数据
     */
    @GetMapping(value = "getJobFreqList")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public List<Map<String, Object>> getJobFreqList() {
        return taskSelectService.getJobFreqList();
    }

    /**
     * 查询分组下拉列表
     *
     * @return Result 返回数据
     */
    @GetMapping(value = "getJobGroupList")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result getJobGroupList() {
        return Result.ok(taskSelectService.getJobGroupList());
    }

    /**
     * 查询调度组下拉列表
     *
     * @return Result 返回数据
     */
    @GetMapping(value = "getGroupNameList")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result getGroupNameList() {
        return Result.ok(taskSelectService.getGroupNameList());
    }

    /**
     * 查询任务状态下拉列表
     *
     * @return Result 返回数据
     */
    @GetMapping(value = "getJobStatusList")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public List<Map<String, Object>> getJobStatusList() {
        return taskSelectService.getJobStatusList();
    }

}
